package com.example.langchain4j_springboot.controller;

import com.example.langchain4j_springboot.Config.QwenAgentExecutor;
import com.example.langchain4j_springboot.Service.Assistant;
import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.community.model.dashscope.QwenEmbeddingModel;
import dev.langchain4j.data.embedding.Embedding;
import dev.langchain4j.data.message.SystemMessage;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.model.output.Response;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/chat")
public class Demo01Controller {

    @Resource
    private Assistant assistant;
    @Resource
    private QwenChatModel qwenChatModel;

    @Resource
    private QwenEmbeddingModel qwenEmbeddingModel;
    @GetMapping("/meseg")
    public String meseg(String message) {
        String chat = assistant.MathChat(message);
        System.out.println(chat);
        return chat;
    }
    @PostMapping("/mesegTool")
    public String mesegTool(String message) {
        String chat = qwenChatModel.chat(SystemMessage.from("你是一位数学老师"),
                        UserMessage.from(message))
                        .aiMessage()
                        .text();
        System.out.println(chat);
        return chat;
    }

}
